<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
	
	<%@ include file="../layout/header.jsp" %>
    
	<!-- 主体部分开始 -->
	<div class="container" style="margin-top:10px;">
		<div class="row">
			<h1>编辑角色</h1>
			<form action="${ctx}/role.do?type=edit" method="post" onsubmit="return validate();">
			  <input type="hidden" id="id" name="id" value="${role.id}">
			  <div class="form-group">
			    <label for="roleName">角色名称</label>
			    <input type="text" class="form-control" id="roleName" name="roleName" value="${role.roleName}" readonly="readonly" placeholder="角色名称">
			  </div>
			  <div class="form-group">
			    <label for="description">角色描述</label>
			    <input type="text" class="form-control" id="description" value="${role.description}" name="description" placeholder="描述信息">
			  </div>
			  <button type="submit" class="btn btn-default">确定</button>
			  <a type="button" href="${ctx}/role.do?type=list" class="btn btn-success">返回</a>
			</form>
		</div>
	</div>
	<!-- 主体部分结束 -->
	
    <%@ include file="../layout/footer.jsp" %>
    
    <script type="text/javascript">
    	
    	function validate(){
    		var flag = true;
    		var roleName = $("#roleName").val();
    		var description = $("#description").val();
    		if(roleName =="" || roleName.length == 0){
    			flag = false;
    			alert("角色名称不能为空！");
    		}
    		if(description =="" || description.length == 0){
    			flag = false;
    			alert("角色描述不能为空！");
    		}
    		return flag;
    	}    	
    
    	$(function(){
    		$("#selectAll").click(function(){
    			$("input[name=selectOne]").each(function(){
    				$(this).prop("checked",!$(this).prop("checked"));
    			})
    		});
    	})
    </script>